<template>
	<view>
		<image class="back_image" src="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-83418c8b-2862-4eac-a6ec-bf64544c5621/cf0b47e3-6906-4da5-acc8-534a8fb4f0ca.jpg" mode="aspectFill"></image>
		<view class="content_view">
			<!-- 导航条 -->
			<view class="stauts_bar_view" :style="{ height: statusbarHeight+'px'}"></view>
			<view class="nav_content">
				<uni-icons class="close_button" type="closeempty" size="30" color="#FFFFFF" @click="closeButtonClick()"></uni-icons>
			</view>
			<!-- 页面其他内容 -->
			<view class="content_title">页面标题</view>
			<!-- 底部的播放器视图 -->
			<view class="custom_play_action_view">
				<!-- 左边的播放模式选择 -->
				<view class="action_view_left" @click="randomButtonClick()">
					<text class="repeat_button" :class="currentSelectedModel.imageSrc"></text>
					<view class="repeat_button_tips">{{ currentSelectedModel.title }}</view>
				</view>
				<!-- 中间的播放暂停按钮 -->
				<image class="play_button" :src="playButtonActionImage" mode="aspectFill" @click="playButtonClick()"></image>
				<!-- 右边的倒计时选择 -->
				<view class="action_view_right" @click="timingButtonClick()">
					<text class="tim_button alifonts icon-dingshi"></text>
					<uni-countdown ref="countdownTimer" :show-day="false" :hour="countdownHour" :minute="countdownMinute" :second="countdownSecond" @timeup="countdownComplete()" color="#FFFFFF" backgroundColor=$zm-main-color splitorColor="#FFFFFF" zmFontSize="30rpx"></uni-countdown>
				</view>
			</view>
		</view>
		<!-- 播放模式列表弹框 -->
		<uni-popup ref="randomPopup" type="bottom">
			<view class="random_pop_list_view">
				<view class="random_action_name">播放模式</view>
				<view class="random_action_item" v-for="(item,index) in playMusicModeArray" :key="index" @click="playModelCellClick(item)">
					<text class="cell_image" :class="item.imageSrc"></text>
					<view class="cell_content">
						<view class="cell_title">{{ item.title }}</view>
						<view class="cell_tips">{{ item.tips }}</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 时间选择弹框 -->
		<xp-picker ref="timePicker" mode="his" value="00:30:00"  @confirm="chooseTimeClick()" @cancel="closeTimingCount()" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusbarHeight: 20,
				/* 播放模式数组 */
				playMusicModeArray: [
					{
						"title":"单曲循环",
						"tips":"循环播放当前音频",
						"imageSrc":"alifonts icon-danquxunhuan",
						"selected":false,
						"type": "1"
					},
					{
						"title":"列表循环",
						"tips":"循环播放当前列表的音频",
						"imageSrc":"alifonts icon-liebiaoxunhuan",
						"selected":false,
						"type": "2"
					},
					{
						"title":"列表随机",
						"tips":"随机播放当前列表的音频",
						"imageSrc":"alifonts icon-suijibofang",
						"selected":false,
						"type": "3"
					}
				],
				/* 当前选择的哪个播放模式 */
				currentSelectedModel: null,
				/* 倒计时时间 */
				countdownHour:0,
				countdownMinute: 30,
				countdownSecond:0,
				/* 当前播放按钮的图片 */
				playButtonActionImage: "../../../static/music_player/music_player_pause.png",
				
			};
		},
		onLoad() {
			const info = uni.getSystemInfoSync();
			this.statusbarHeight = info.statusBarHeight;
			this.currentSelectedModel = this.playMusicModeArray[0];
		},
		methods: {
			/* 导航条返回按钮点击 */
			closeButtonClick() {
				uni.navigateBack();
			},
			/* 左边的播放模式按钮点击 */
			randomButtonClick() {
				this.$refs.randomPopup.open();
			},
			/* 右边的定时按钮点击 */
			timingButtonClick() {
				this.$refs.timePicker.show()
			},
			/* 中间的播放暂停按钮点击 */
			playButtonClick() {
				this.playButtonActionImage = "../../../static/music_player/music_player_pause.png";
				this.playButtonActionImage = "../../../static/music_player/music_player_play.png";
			},
			/* 倒计时完成按钮点击 */
			countdownComplete() {
				console.log("倒计时完成");
			},
			/* 播放模式选择 */
			playModelCellClick(item) {
				// 选择播放模式
				this.currentSelectedModel = item;
				this.$refs.randomPopup.close();
			},
			/* 时间选择 */
			chooseTimeClick(e) {
				let timeArray = e.value.split(':');
				this.countdownHour = timeArray[0];
				this.countdownMinute = timeArray[1];
				this.countdownSecond = timeArray[2];
				this.$refs.countdownTimer.play();
			},
			/* 关闭定时 */
			closeTimingCount() {
				console.log("关闭定时");
				this.$refs.countdownTimer.timeUp();
				
			},
			
		}
		
	}
</script>

<style lang="scss">
	//===== 背景页面 =======//
	.back_image {
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		z-index: -1;
		
		// css animation
		animation-name: scaleanimation; // 动画名称
		animation-duration: 8s; // 动画持续时间
		animation-direction: alternate; // 轮流反向播放动画
		animation-iteration-count: infinite; // 动画播放的次数
		animation-timing-function: linear; // 动画的速度曲线
	}
	
	@keyframes scaleanimation {
		from {scale: 1;}
		to {scale: 1.2;}
	}

	//===== 内容页面 =======//
	.content_view {
		
	}
	
	.nav_content {
		height: 44px;
		display: flex;
		align-items: center;
	}
	.close_button {
		margin-left: 20rpx;
	}
	
	//====== 标题 =======//
	.content_title {
		text-align: center;
		margin: 20rpx;
		font-size: 40rpx;
		color: #FFFFFF;
	}
	
	
	//===== 播放操作视图 =======//
	.custom_play_action_view {
		// 距离底部布局
		position: absolute;
		bottom: 150rpx;
		width: 700rpx;
		margin-left: 25rpx;
		margin-right: 25rpx;
		border-radius: 10rpx;
		
		// 内部控件布局
		display: flex;
		background-color: #2B2B2B;
		justify-content: space-between;
		align-items: center;
		opacity: 0.8;
	}
	
	.action_view_left {
		width: 300rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		
		.repeat_button {
			font-size: 60rpx;
			color: #FFFFFF;
		}
		
		.repeat_button_tips {
			font-size: 30rpx;
			color: #FFFFFF;
		}
	}
	
	.play_button {
		width: 100rpx;
		height: 100rpx;
	}
	
	.action_view_right {
		width: 300rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		
		.tim_button {
			font-size: 60rpx;
			color: #FFFFFF;
		}
	}
	
	// 播放模式弹出动画
	.random_pop_list_view {
		background-color: #FFFFFF;
		width: 100%;
		border-radius: 16rpx;
		
		.random_action_name {
			font-size: 36rpx;
			font-weight: bold;
			color: #000000;
			text-align: center;
			width: 100%;
			padding-top: 30rpx;
			padding-bottom: 30rpx;
		}
		
		.random_action_item {
			display: flex;
			padding-bottom: 50rpx;
			align-items: center;
			
			.cell_image {
				font-size: 48rpx;
				color: #000000;
				padding-left: 30rpx;
			}
			
			.cell_content {
				padding-left: 30rpx;
				
				.cell_title {
					font-size: 30rpx;
					font-weight: bold;
					padding-bottom: 5rpx;
				}
				
				.cell_tips {
					padding-top: 5rpx;
					font-size: 24rpx;
					font-weight: normal;
					color: #AAAAAA;
				}
				
			}
			
		}
		
	}
	
	
	

</style>
